construct a square from line segment